<template>
  <div>
    <div class="user-header">
      <div class="user-header-info">
        <div class="user-header-info-name">
          <p class="user-header-info-name-l">
            {{ pointData ? pointData.name : '--' }}
            <em>执行中</em>
          </p>
        </div>
        <p class="user-header-info-address">
          <span class="name-title">
            驻点所在地
          </span>
          <span class="name-value">
             {{ pointData ? `${pointData.inAddress}` : '--' }}
          </span>
        </p>
        <p class="user-header-info-address">
          <span class="name-title">
            所属项目
          </span>
          <span class="name-value">
            {{ projectData ? projectData.name : '--' }}
          </span>
        </p>
        <p class="user-header-info-address">
          <span class="name-title">
            所属客户
          </span>
          <span class="name-value">
            {{userData?userData.name: ''}}
          </span>
        </p>
        <div class="user-header-info-call">
          <div class="user-header-info-call-p">
            <p><span
              class="name-title">负责人</span>{{ pointData ? (pointData.sysUser ? pointData.sysUser.nickName : '') : '' }}
            </p>
            <p><span
              class="name-title">负责人电话</span>{{
                pointData ? (pointData.sysUser ? pointData.sysUser.phonenumber : '') : ''
              }}
            </p>
          </div>
          <div class="user-header-info-call-r">
            <p class="user-header-info-call-r-title">驻点人数</p>
            <div class="user-header-info-call-r-work">
              <p>{{ numerTeam }}人</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="my-tabs">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="基本信息" name="infoPoint"></el-tab-pane>
        <el-tab-pane label="团队" name="team"></el-tab-pane>
        <el-tab-pane label="排班" name="scheduling"></el-tab-pane>
        <el-tab-pane label="考勤" name="attendance"></el-tab-pane>
        <el-tab-pane label="班次配置" name="classesList"></el-tab-pane>
        <el-tab-pane label="岗位" name="post"></el-tab-pane>
      </el-tabs>
    </div>
    <div class="user-table">
      <component :is="activeName" :paramId="paramId" :projectData="projectData" :pointData="pointData"
                 @getPointFn="getPointFn" v-if="pointData" :type="type" :pointId="pointId"/>
    </div>
    <newAdd></newAdd>
  </div>
</template>

<script>
import infoPoint from "./components/infoPoint";
import post from "./components/post";
import team from "./components/team";
import scheduling from "./components/scheduling";
import attendance from "./components/attendance";
import classesList from "./components/classesList";
import {
  getStagnationPoint
} from "@/api/system/stagnation_point";
import {
  getProject
} from "@/api/system/project";
import newAdd from "@/components/zhudian-team/newAdd";
import {getCustom} from '@/api/system/custom.js'

export default {
  name: "detail",
  props: ['type', 'pointId'],
  components: {
    infoPoint,
    post,
    team,
    scheduling,
    attendance,
    newAdd,
    classesList
  },
  data() {
    return {
      activeName: 'infoPoint',
      paramId: 0,
      projectData: null,
      pointData: null,
      numerTeam: 0,
      userData: null
    };
  },
  created() {
    if (this.type == 'homeindex') {
      this.paramId = this.pointId;
    } else {
      this.paramId = this.$route.params && this.$route.params.pointId;
    }
    this.getPointFn()
  },
  methods: {
    getPointFn() {
      getStagnationPoint(this.paramId).then(response => {
        console.log('response:', response)
        this.pointData = this.$deepCopy(response.data.detail)
        this.numerTeam = response.data.number
        this.getProject(response.data.detail.projectId)
        this.getUserDetail()
      })
    },
    // 项目
    getProject(id) {
      getProject(id).then(res => {
        console.log('项目', res)
        this.projectData = this.$deepCopy(res.data.detail);
      })
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
// 客户详情
    getUserDetail() {
      getCustom(this.pointData.customId).then(res => {
        this.userData = res.data
      })
    },
  }
}
</script>

<style scoped>
.user-header {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 10px;
}

.user-header {
  display: flex;
}

.user-header-img {
  margin-right: 40px;
}

.user-header-img img {
  width: 186px;
}

.user-header-info {
  flex: 1;
}

.user-header-info p {
  margin: 0;
}

.user-header-info-name {
  font-size: 18px;
  font-weight: 500;
  display: flex;
  margin-bottom: 10px !important;
  align-items: center;
}

.user-header-info-name-l {
  flex: 1;
  display: flex;
}

.user-header-info-name em {
  font-size: 12px;
  background: green;
  color: #fff;
  font-style: normal;
  margin-left: 10px;
  height: 22px;
  line-height: 22px;
  width: 50px;
  text-align: center;
  display: block;
  border-radius: 11px;
}

.user-header-info-address {
  font-size: 12px;
}

.user-header-info-address span {
  color: rgba(0, 0, 0, .3);
}

.user-header-info-address em {
  color: #ffba00;
  font-style: normal;
}

.user-header-info-address .name-value {
  color: #000;
}

.name-title {
  margin-right: 20px;
}

.user-header-info-call {
  margin-top: 10px;
  border-top: 1px dashed #f4f4f4;
  width: 100%;
  padding-top: 20px;
  display: flex;
  font-size: 12px;
}

.user-header-info-call-p {
  flex: 1;
  border-right: 1px solid #f4f4f4;
}

.user-header-info-call-p p {
  margin-bottom: 10px;
}

.user-header-info-call-p span {
  color: rgba(0, 0, 0, .3);
}

.user-header-info-call-r {
  width: 130px;
  border-right: 1px solid #f4f4f4;
  padding: 0 20px;
}

.user-header-info-call-r-title {
  margin-bottom: 10px !important;
  color: rgba(0, 0, 0, .3);
}

.user-header-info-call-r-work {
  font-size: 14px;
}

.user-table {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
}

.user-btn-status {
  border: 1px solid #ddd;
  font-size: 12px;
  display: flex;
  align-items: center;
  border-radius: 15px;
  overflow: hidden;
}

.user-btn-status span {
  cursor: pointer;
  padding: 0 20px;
  height: 30px;
  display: block;
  line-height: 30px;
}

.user-btn-status span:first-child {
  border-right: 1px solid #ddd;
}

.user-btn-status span:hover {
  background: #f8f8f8;
}

.my-tabs {
  padding: 0 20px;
}


</style>
